package com.example.agent;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import java.lang.reflect.Proxy;

public class MainActivity {

    public static void main(String[] args) {
        IShop yangGuiZhong = new YangGuiZhong();
//        IShop chennong = new ChenNong(yangGuiZhong);
//        chennong.buy();
        DynamicChenNonging dynamicChenNonging = new DynamicChenNonging(yangGuiZhong);
        ClassLoader classLoader = yangGuiZhong.getClass().getClassLoader();
        IShop iShop = (IShop)Proxy.newProxyInstance(classLoader, new Class[]{IShop.class}, dynamicChenNonging);
        iShop.buy();
    }
}